<%--
  Created by IntelliJ IDEA.
  User: LSK
  Date: 2022/11/25
  Time: 13:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>查看订单</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/bootstrap-3.4.1-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/bootstrap-3.4.1-dist/css/bootstrap-theme.min.css">
    <!--  -->
    <script src="${pageContext.request.contextPath}/bootstrap-3.4.1-dist/js/jquery-3.3.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/bootstrap-3.4.1-dist/js/bootstrap.min.js"></script>
    <!-- 导入 layui -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
    <script src="${pageContext.request.contextPath}/layui/layui.js"></script>
    <script src="${pageContext.request.contextPath}/layer.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.4.1.js"></script>
    <script type="text/javascript">
        $(function (){
            //点击删除
            $("#delBtn").click(function () {
                var $checkboxs = $("#tbody input[type='checkbox']:checked");
                var ids="";
                $.each($checkboxs,function (index,obj) {

                    ids+="id="+obj.value+'&';

                })
                ids=ids.substr(0,ids.length-1);
                //表单验证
                if ($checkboxs.size==0){
                    alert("请勾选要删除的数据");
                    return;
                }
                //发起请求
                if(window.confirm("确定删除数据吗？")){
                    $.ajax({
                        url:'${pageContext.request.contextPath}/order/deleteOrderByIds',
                        dataType:'json',
                        type:'post',
                        data:ids,
                        success:function (data) {
                            alert(data.message)
                            if (data.code==1){
                                window.location.href="${pageContext.request.contextPath}/order/1/10/0";
                            }

                        }
                    })
                }
            });
            //取消删除
            $("#NodelBtn").click(function () {
                var $checkboxs = $("#tbody input[type='checkbox']:checked");
                for (let i = 0; i < $checkboxs.length; i++) {
                    var o=$checkboxs[i];
                    o.checked=false;
                }
            });
        })
    </script>
    <style>
        input{
            color: white;
            background-color: #ef4238;
            position: center;
            border-radius: 20px;
            font-size: 16px;
            border: none;
        }
        #delBtn{
            width: 42px;
        }
        #NodelBtn{
            width: 72px;
        }
    </style>
</head>
<body>
<div style="margin: 0 auto">
    <table class="layui-table " id="tab1" style="margin-bottom: 50px !important;">
        <caption>订单列表</caption>
        <colgroup>
            <col width="150">
            <col width="200">
            <col>
        </colgroup>
        <thead>
        <tr>
            <th>
                <input type="button" value="删除" id="delBtn">
                <input type="button" value="取消删除" id="NodelBtn">
            </th>
            <th>订单编号</th>
            <th>电影名</th>
            <th>概述</th>
            <th>支付价格</th>
            <th>支付时间</th>
        </tr>
        </thead>
        <tbody id="tbody">
        <c:forEach var="orderDto" items="${orderDtoList}" varStatus="st">
        <tr>
            <td><input type="checkbox" lay-skin="primary" value="${orderDto.myorder.orderId}"></td>
            <td>${orderDto.myorder.orderNumber}</td>
            <td>${orderDto.proName}</td>
            <td>${orderDto.proDesc}</td>
            <td>${orderDto.myorder.orderPrice}</td>
            <td>${orderDto.myorder.orderCreateTime}</td>
        </tr>
        </c:forEach>
        </tbody>
    </table>

</div>
<div>
<%--     @PostMapping("/{currentPage}/{pageSize}/{a}")--%>
    <ul class="pagination">
        <c:forEach var="idx"  begin="1" end="${total}">
            <li><a href="${pageContext.request.contextPath}/order/${idx}/5/0">${idx}</a></li>
        </c:forEach>
<%--        <li><a href="${pageContext.request.contextPath}/order/1/6/0">1</a></li>--%>
<%--        <li><a href="${pageContext.request.contextPath}/order/2/5/0">2</a></li>--%>
<%--        <li><a href="${pageContext.request.contextPath}/order/3/5/0">3</a></li>--%>
<%--        <li><a href="${pageContext.request.contextPath}/order/4/5/0">4</a></li>--%>
<%--        <li><a href="${pageContext.request.contextPath}/order/5/5/0">5</a></li>--%>
<%--        <li><a href="${pageContext.request.contextPath}/order/6/5/0">6</a></li>--%>
<%--        <li><a href="${pageContext.request.contextPath}/order/7/5/0">7</a></li>--%>
<%--        <li><a href="${pageContext.request.contextPath}/order/8/5/0">8</a></li>--%>
<%--        <li><a href="${pageContext.request.contextPath}/order/9/5/0">9</a></li>--%>
<%--        <li><a href="${pageContext.request.contextPath}/order/10/5/0">10</a></li>--%>
<%--        <li><a href="${pageContext.request.contextPath}/order/11/5/0">11</a></li>--%>
<%--        <li><a href="${pageContext.request.contextPath}/order/12/5/0">12</a></li>--%>
    </ul>
</div>
</body>
</html>
